package com.hnhs.service;

import com.hnhs.info.ProductStatusUpdate;
import com.hnhs.mapper.CategoryMapper;
import com.hnhs.mapper.ProductMapper;
import com.hnhs.model.Category;
import com.hnhs.model.CategoryQuery;
import com.hnhs.model.Product;
import com.hnhs.model.ProductQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProductService {
    @Autowired
    private ProductMapper mapper;

    public List<Product> select(ProductQuery query){

        return mapper.select(query);
    }

   public int insert(Product product){
        //交给你们作 里面加个判断
        return mapper.insert(product);
    }
   public  int update(Product product){
        return mapper.update(product);
    }
    //删除 采用软删除 就是更改status
    public int delete(Integer id){

        return mapper.updateStatus(id,1);
    }

    public Integer updateStatus(ProductStatusUpdate update) {
        return  mapper.updateStatus(update.getId(),update.getStatus());
    }
}
